/*
 * Filename    : ButtonShootCooldown.java
 * Projectname : RamaShinta
 * Date        : Dec 28, 2012 , 12:49:37 PM 
 * 
 */

package com.amikomgamedev.ramashinta;

import java.util.Timer;
import java.util.TimerTask;

public class ButtonShootCooldown
{
	private boolean						valid;
	private Timer						timer;
	private long						delay		= 1000;
	private long						speedUp		= 400;
	private long						slow		= 3000;
	private static ButtonShootCooldown	instance	= null;

	public ButtonShootCooldown()
	{
		// TODO Auto-generated constructor stub
		timer = new Timer();
		valid = true;
	}

	public static ButtonShootCooldown getInstance()
	{
		if (instance == null)
			instance = new ButtonShootCooldown();
		return instance;
	}

	public boolean checkValid()
	{
		if (valid)
		{
			valid = false;
			timer.schedule(new Task(), delay);
			return true;
		}
		return false;

	}

	public boolean superSpeed()
	{
		if (valid)
		{
			valid = false;
			timer.schedule(new Task(), speedUp);
			return true;
		}
		return false;

	}
	
	public boolean superSlow()
	{
		if (valid)
		{
			valid = false;
			timer.schedule(new Task(), slow);
			return true;
		}
		return false;

	}

	class Task extends TimerTask
	{
		public void run()
		{
			valid = true;
		}
	}

}
